<?php
/**
 * Created by PhpStorm.
 * User: eugene
 * Date: 2018/3/15
 * Time: 14:16
 */

namespace App\Transformers;


use App\Models\Member;
use App\Repos\MemberRepo;
use Carbon\Carbon;

class MessageTransformer extends Transformer
{
    public function transform($item)
    {
        
        return [
            'id'=>$item->id,
            'from_user'=>(new MemberTransformer())->setTransformer('forSimple')->singleData(Member::find($item->user_id)),
            'message_text'=>$item->text,
            'created_at'=>Carbon::parse($item->created_at)->diffForHumans(Carbon::now()),
            'type'=>$item->type,//1 我的车辆状态改变, 2 我的车位状态改变
        ];
    }
    
}